package cn.tiger;

public class MultPlus {
    private volatile int num = 0;

    private int getNum() {
        return num;
    }

    private synchronized void addNum() {
        num++;
    }

    public static void main(String[] args) {
        MultPlus multPlus = new MultPlus();
        for (int i = 0; i < 100; i++) {
            synchronized (multPlus) {
                new Thread(multPlus::addNum).start();
            }
        }
        System.out.println(multPlus.getNum());
    }
}
